package com.example.leetcode.graph.common;

public class Edge {
    // 有向边的起点
    public int from;
    // 有向边的终点
    public int to;

    // 权重
    public int weight;
    public double w;

    // true 表示有向边 false 无向边
    boolean direction;

    // 无向边的两端点
    public int point1;
    public int point2;

    public Edge(int from, int to) {
        this.from = from;
        this.to = to;
    }

    /**
     * 默认是有向边
     *
     * @param from
     * @param to
     * @param weight
     */
    public Edge(int from, int to, int weight) {
        this.from = from;
        this.to = to;
        this.weight = weight;
        this.direction = true;
    }

    public Edge(int from, int to, double w) {
        this.from = from;
        this.to = to;
        this.w = w;
    }

    /**
     * direction = true 有向边， 否则 无向边
     *
     * @param from
     * @param to
     * @param weight
     * @param direction
     */
    public Edge(int from, int to, int weight, boolean direction) {
        this.weight = weight;
        this.direction = direction;
        if (direction) {
            // 有向边
            this.from = from;
            this.to = to;
        } else {
            // 无向边
            this.point1 = from;
            this.point2 = to;
        }
    }
}
